package springboot.Controller;

import springboot.common.Result;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import org.springframework.web.bind.annotation.*;
import javax.annotation.Resource;
import java.util.List;
import springboot.service.ILjhsRoleService;
import springboot.entity.LjhsRole;
import org.springframework.web.bind.annotation.RestController;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author hys
 * @since 2022-06-04
 */
@RestController
@RequestMapping("/ljhs-role")
public class LjhsRoleController {
    @Resource
    private ILjhsRoleService ljhsRoleService;

    @PostMapping

    public Result save(@RequestBody LjhsRole ljhsRole){

        return Result.success(ljhsRoleService.saveOrUpdate(ljhsRole));
        }

        @DeleteMapping("/{id}")

        public Result delete(@PathVariable Integer id){

        return Result.success(ljhsRoleService.removeById(id));
        }
        @PostMapping("/batch/del")
        public Result deleteBatch(@RequestBody List<Integer> ids){

        return Result.success(ljhsRoleService.removeByIds(ids));
        }
        @GetMapping

        public Result index(){

        return Result.success(ljhsRoleService.list());
        }

        @GetMapping("/{id}")

        public Result findOne(@PathVariable Integer id) {
        return Result.success(ljhsRoleService.getById(id));
        }

        @GetMapping("/page")

        public Result findPage(@RequestParam Integer pageNum,
                                        @RequestParam Integer pageSize) {
        return Result.success(ljhsRoleService.page(new Page<>(pageNum, pageSize)));
        }


}

